<template>
  <div :class="appContainerCssClass">
    <div class="filter-container">
      <!--
      a-form-model rules 对动态标签处理时，item-label * 号不出现,需一开始指定，必须绑定,所直接在a-form-model-item标签中直接绑定，也要提取准备好require=true，先设置true，最后再根据规则调整位false
      -->
      <a-form-model ref="ruleForm" :model="formModel" layout="inline">
        <a-row v-for="(rowItem ,rowIndex) in formRowCollapseKey['noCollapseKey']" :key="rowIndex" :gutter="rowItem.gutter">
          <a-col v-for="(formItem,colIndex) in formRowActiveData[rowItem.rowKey].colList" :key="colIndex" :span="formItem.span">
            <input-tpl-ui
              v-show="rowItem.rowType === 'form'"
              ref="modalFormTplUi"
              :param-data="initData"
              :form-item="formColActiveData[formItem.model]"
              :active-enum-list="activeEnumData[formItem.model]"
              :active-enum-data="activeEnumData"
              :modal-fn-data="modalFn"
              :ui-page-url="uiPageUrl"
              :init-src-label="initSrcObj.initSrcLabel"
              :rules="rules"
              :modal-form="formModel"
              :form-event="formEvent"
              @selectSearch="inputSelectSearch"
              @inputSearch="inputSearch"
              @changeEvent="inputChangeEvent"
              @clearEmpty="clearEmpty"
            />
          </a-col>
        </a-row>
      </a-form-model>
    </div>
    <div class="table-operator">
      <div v-if="showChart.defaultShow" :id="tableEchartId" style="width: 100%;height: 270px" />
    </div>
    <div class="table-operator">
      <!-- <div style="display: flex; flex-wrap: wrap"> -->
      <operator-btn-tpl-list
        :session-config-tpl-data="sessionConfigTplData"
        :toolbar-menu-data="tableToolbarMenu"
        :toolbar-list-data="tableToolbarList"
        :table-selected-key-data="tableSelectedKey"
        :ui-page-url="uiPageUrl"
        @tableOperatorBtnOnClick="tableOperatorBtnOnClick"
        @tableOperatorBtnUpload="tableOperatorBtnUpload"
      />
    </div>
    <span>
      <div v-if="tableSelectTips" class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon" /> 已选择 <a style="font-weight: 600">{{ tableSelectedKey.length }}</a>项
        <a style="margin-left: 24px" @click="tableClearSelected">清空</a>
      </div>

      <a-table
        :ref="tableId"
        table-layout="auto"
        fixed="true"
        :bordered="tableBordered"
        :row-key="tableRowKey"
        :size="tableSize"
        :loading="loading"
        :pagination="tablePagination"
        :row-selection="{selectedRowKeys: tableSelectedKey,onChange: tableOnSelect,type:rowSelectType}"
        :columns="listColActiveList"
        :custom-row="processCustomRow"
        :data-source="tableData"
        :scroll="tableScroll"
        @change="tableOnChange"
      >
        <span v-for="(titleIcon) in titleIconList" :slot="titleIcon.slot" :key="titleIcon.slot">
          <a-icon v-if="titleIcon.leftIcon !== undefined" :type="titleIcon.leftIcon.icon" @click="clickIconEvent(titleIcon)" /> {{ titleIcon.title }}
          <a-icon v-if="titleIcon.rightIcon !== undefined" :type="titleIcon.rightIcon.icon" @click="clickIconEvent(titleIcon)" />
          <a-tooltip v-if="titleIcon.tooltipIcon !== undefined" :title="titleIcon.tooltipIcon.title">
            <a-icon :type="titleIcon.tooltipIcon.icon" />
          </a-tooltip>
        </span>
        <!--{ x: 1100 }滚动宽度 -->
        <!--        <template v-if="initHeadTitle" slot="title" slot-scope="text,record,rowIndex,rowColumn">-->
        <!--          Header-->
        <!--        </template>-->
        <div
          slot="filterDropdown"
          slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }"
          style="padding: 8px"
        >
          <a-input
            v-ant-ref="c => (searchInput = c)"
            :placeholder="`查找 ${column.title}`"
            :value="selectedKeys[0]"
            style="width: 188px; margin-bottom: 8px; display: block;"
            @change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
            @pressEnter="() => handleSearch(selectedKeys, confirm, column.dataIndex)"
          />
          <a-button
            type="primary"
            icon="search"
            size="small"
            style="width: 90px; margin-right: 8px"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex)"
          >
            查询
          </a-button>
          <a-button size="small" style="width: 90px" @click="() => handleReset(clearFilters)">
            重置
          </a-button>
        </div>
        <a-icon
          slot="filterIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <template slot="progress" slot-scope="text,record,rowIndex,rowColumn">
          <span>
            <a @click="processOnClick(text,record,rowIndex,rowColumn)">
              {{ text }}
            </a>
          </span>
        </template>
        <span slot="input" slot-scope="text, record,rowIndex,rowColumn">
          <a-input
            style="margin: -5px 0"
            :value="text"
            @change="e => tableInputChange(e.target.value, rowColumn.dataIndex, rowIndex)"
          />
        </span>
        <span slot="inputNumber" slot-scope="text, record,rowIndex,rowColumn">
          <a-input-number
            style="width: 100%"
            :value="text"
            step="10"
            @change="e => tableInputNumberChange(e, rowColumn.dataIndex, rowIndex)"
          />
        </span>
        <span slot="select" slot-scope="text, record,rowIndex,rowColumn">{{columnFiltersData.S_OBJ_MSG}}}
          <a-select style="width: 120px" @change="e => tableInputChange(e, rowColumn.dataIndex, rowIndex)" :value="text">
            <a-select-option v-for="(data,i) in activeEnumData[rowColumn.dataIndex]" :key="data.value">
              {{ data.text }}
            </a-select-option>
          </a-select>
        </span>
        <span slot="switch" slot-scope="text, record,rowIndex,rowColumn">
          <a-switch :checked="text" default-checked @change="e => tableInputChange(e, rowColumn.dataIndex, rowIndex)" />
        </span>
        <span slot="tags" slot-scope="text, record,rowIndex,rowColumn">
          <a-tag
            v-for="tag in customRowIdxTagsObj[rowColumn.dataIndex][rowIndex]"
            :key="tag"
            :color="tag === 'loser' ? 'volcano' : tag.length > 5 ? 'geekblue' : 'green'"
          >
            {{ tag.toUpperCase() }}
          </a-tag>
        </span>
        <span slot="icon" slot-scope="text">
          <a-icon :type="text" />
        </span>
        <span slot="avatar" slot-scope="text">
          <a-avatar :src="text" />
        </span>
        <!--        <p slot="expandedRowRender" slot-scope="text, record,rowIndex,rowColumn" style="margin: 0">-->
        <!--          {{ record.description }}-->
        <!--        </p>-->
        <span slot="action" slot-scope="text, record,rowIndex,rowColumn">
          <span v-for="(btnItem,index) in customRowIdxBtnObj[rowColumn.dataIndex][rowIndex]" :key="index">
            <span v-if="btnItem.compTag === 'text'" :key="index">{{ btnItem.name }}{{ text }}
            </span>
            <router-link v-else-if="btnItem.compTag === 'r'" :key="index" :to="{query:{id:1}}" target="_blank">
              {{ btnItem.name }}
            </router-link>
            <a-popconfirm v-else-if="btnItem.compTag === 'confirm'" :key="index" :title="btnItem.title" @[btnItem.eventName]="columnBtnOnClick(btnItem, record)">
              <a>{{ btnItem.name }}</a>
            </a-popconfirm>
            <a v-else :key="index" @[btnItem.eventName]="columnBtnOnClick(btnItem, record)">
              <a-icon v-if="btnItem.leftIcon !== undefined" :type="btnItem.leftIcon.icon" @click="clickIconEvent(btnItem)" /> {{ btnItem.name }}{{ text }}
              <a-icon v-if="btnItem.rightIcon !== undefined" :type="btnItem.rightIcon.icon" @click="clickIconEvent(btnItem)" />
              <a-tooltip v-if="btnItem.tooltipIcon !== undefined" :title="btnItem.tooltipIcon.title">
                <a-icon :type="btnItem.tooltipIcon.icon" />
              </a-tooltip>
            </a>
            <a-divider v-if="(customRowIdxBtnObj[rowColumn.dataIndex][rowIndex] !== undefined && customRowIdxBtnObj[rowColumn.dataIndex][rowIndex].length -1) > index" :type="tableDividerType" />
          </span>
          <a-divider v-if="customRowIdxBtnObj[rowColumn.dataIndex][rowIndex] !== undefined && customRowIdxBtnObj[rowColumn.dataIndex][rowIndex].length > 0 && customRowIdxMenuObj[rowColumn.dataIndex][rowIndex].length > 0" :type="tableDividerType" />
          <a-dropdown v-if="customRowIdxBtnObj[rowColumn.dataIndex][rowIndex] !== undefined && customRowIdxMenuObj[rowColumn.dataIndex][rowIndex].length > 0">
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item v-for="(menuItem,index) in customRowIdxMenuObj[rowColumn.dataIndex][rowIndex]" :key="index">
                <a v-show="menuItem.show" v-if="menuItem.compTag === 'a'" @[menuItem.eventName]="columnBtnOnClick(menuItem, record)">
                  <a-icon v-if="menuItem.leftIcon !== undefined" :type="menuItem.leftIcon.icon" @click="clickIconEvent(menuItem)" /> {{ menuItem.name }}{{ text }}
                  <a-icon v-if="menuItem.rightIcon !== undefined" :type="menuItem.rightIcon.icon" @click="clickIconEvent(menuItem)" />
                  <a-tooltip v-if="menuItem.tooltipIcon !== undefined" :title="menuItem.tooltipIcon.title">
                    <a-icon :type="menuItem.tooltipIcon.icon" />
                  </a-tooltip>
                </a>
                <a-popconfirm v-else-if="menuItem.compTag === 'confirm'" :title="menuItem.title" @[menuItem.eventName]="columnBtnOnClick(menuItem, record)"><a>{{ menuItem.name }}</a></a-popconfirm>
                <a v-else @[menuItem.eventName]="columnBtnOnClick(menuItem, record)">
                  <a-icon v-if="menuItem.leftIcon !== undefined" :type="menuItem.leftIcon.icon" @click="clickIconEvent(menuItem)" /> {{ menuItem.name }}{{ text }}
                  <a-icon v-if="menuItem.rightIcon !== undefined" :type="menuItem.rightIcon.icon" @click="clickIconEvent(menuItem)" />
                  <a-tooltip v-if="menuItem.tooltipIcon !== undefined" :title="menuItem.tooltipIcon.title">
                    <a-icon :type="menuItem.tooltipIcon.icon" />
                  </a-tooltip>
                </a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </span>
    <!--    <template slot="footer">-->
    <!--      <a-button @click="handleCancel">取消</a-button>-->
    <!--      <a-button type="primary">驳回</a-button>-->
    <!--      <a-button type="primary" @click="handleOk">确定</a-button>-->
    <!--    </template>-->
  </div>

</template>

<script>

import {
  changeListColActiveData,
  initListColActive, beforeInitData,
  searchSessionFormData,
  searchSessionTpl, loadSessionFormData, loadSessionUIData
} from '../../../../utils/hylist'

const tableColumns = []
const tableData = []
import { submitDealReq, getDealParam } from '@/utils/auth'
import { executeRecord, getGlobalParam, deleteLocalList, deleteBatchLocalList, deleteBatchRemoteRecord, deleteRemoteRecord } from '@/utils/hyrecord'
import { initToolbar, changeToolbar, initToolbarMenu, changeToolbarMenu, initColumnListBtn, initRowBtn, initFooterToolbarList } from '@/utils/hybtn'
import { initEnumParam, changeLoadEnumList } from '@/utils/hyenum'
import { initColumnList, changeColumnList, initTableEvent, changeTableEvent, fetchPageData, changeSelectRow, initTableRowKey } from '@/utils/hylist'

import { initForm, changeForm, handleInit, initFormFnParam, changeFormFnParam, changeFormKeyFnParam, changeFormRowActiveData } from '@/utils/hyform'
import { initRules, changeFormRules, changeFormKeyRules,initLazyFormRules } from '@/utils/hyformrules'
import { btnUploadFile } from '@/utils/hyupload'
import { initFormListWidth } from '@/utils/hyscreenWidth'
import { getRefOpenObj, getOpenLocalFormModel } from '@/utils/hyopen'
import { initDealApi, getFnInputParam } from '@/utils/hyurl'
import { inputChangeEventControlObj, getCallFnByFnType, inputChangeEvent, execClickBtn } from '@/utils/hyctr'
import inputTplUi from './inputTplUi'
import operatorBtnTplList from './operatorBtnTplList'
import { I_APP_ID } from '@/settings'
// import columnBtnTplList from './columnBtnTplList'
import request from '@/utils/request'
import vm from 'vm'
import echarts from 'echarts'
import resize from '@/components/Charts/mixins/resize'
import { getOpenLocalFormList, getOpenLocalSessionTplList } from '../../../../utils/hyopen'

const columns = [
  { title: 'Full Name', width: 100, dataIndex: 'S_ID', key: 'S_ID', fixed: 'left',
    scopedSlots: { customRender: 'inputs' }},
  { title: 'Age', width: 100, dataIndex: 'age', key: 'age', fixed: 'left' },
  { title: 'Column 1', dataIndex: 'address', key: '1' },
  { title: 'Column 2', dataIndex: 'address', key: '2' },
  { title: 'Column 3', dataIndex: 'address', key: '3' },
  { title: 'Column 4', dataIndex: 'address', key: '4' },
  { title: 'Column 5', dataIndex: 'address', key: '5' },
  { title: 'Column 6', dataIndex: 'address', key: '6' },
  { title: 'Column 7', dataIndex: 'address', key: '7' },
  { title: 'Column 8', dataIndex: 'address', key: '8' },
  {
    title: 'Action',
    key: 'operation',
    fixed: 'right',
    width: 100,
    scopedSlots: { customRender: 'action' }
  }
]
const options = [
  { text: 'Apple', value: 'Apple' },
  { text: 'Pear', value: 'Pear' },
  { text: 'Orange', value: 'Orange' }
]
export default {
  name: 'TableTplView',
  components: { inputTplUi, operatorBtnTplList },
  mixins: [resize],
  props: ['S_PAGE_ID', 'S_PAGE_VER', 'S_PARTITION', 'tableTplListUiData', 'tableEvent', 'tableId', 'paramData', 'tableObjParam', 'uiPageUrl', 'tableEchartId', 'appContainnerCssObj', 'defPanelWidth'],
  data() {
    return {
      appContainerCssClass: 'app-container',
      appDefaultContainerCssClass: 'app-container',
      appInnerContainerCssClass: 'app-inner-container',
      globalData: {},
      triggerOpenParam: {},
      searchText: '',
      searchInput: null,
      searchedColumn: '',
      checkBoxValue: [],
      options: options,
      initHeadTitle: false,
      initLoadObj: { loadFormId: '', loadBtnId: '', loadListId: '', loadPanelId: '', loadPanelVer: '', panelWidth: 100 },
      initSrcObj: { initSrcUrl: undefined, initSrcLabel: undefined, initSrcSearch: true },
      initReturnSetFormData: {},
      initReturnSetListData: {},
      uiParamData: {},
      initOpenData: {},
      initFormKey: 'formList',
      initTableKey: 'tableTplList',
      initUiVal: {}, // 初始化满足条件当前呈现UI数据
      rules: { }, // 查询条件校验规则
      openParam: {}, // 开窗数据
      initData: {}, // 查询条件初始化数据
      remoteDataSet: {},
      openReturnData: {}, // 开窗返回参数
      clickRow: {}, // 点击事件记录
      validatorRules: {},
      viewChart: null,
      showChart: { defaultShow: false },
      ehUrlKey: {},
      lazyFormRules: {},
      // inputStyle: 'width: 260px',
      // screenWidthFix: 1.1,
      // inputWidthFix: 0.75,
      // panelWidth: 100,
      clientWidth: 920,
      nowBtnItem: {},
      fileData: {},
      collapseKey: {},
      formList: { },
      formKey: [],
      modalFn: {},
      modalFnShow: {},
      selection: [],
      selectCellRow: null,
      selectCellCol: null,
      selectCell: null,
      pagination: {
        size: 10,
        num: 1
      },
      total: 0,
      queryParams: {},
      rowSelectType: 'checkbox',
      // rowSelectType: 'radio',
      tableSelectTips: false,
      // tableId:'table',
      tableScroll: { x: 550 },
      tableDividerType: 'vertical',
      tableBordered: true,
      tableRowKey: 'S_ID',
      checkable: true,
      tableSize: 'middle',
      loading: false,
      titleIconList: [],
      tableRightMenu: { },
      tableFirstRow: {},
      tableSelectedKey: [],
      tableSelectedRow: [],
      tableSelectedNode: null,
      tableDropTrigger: '',
      tableQueryParam: { iPageNo: 1 },
      enumParam: {},
      tableEnumData: {},
      tableColumns: tableColumns,
      tableData: tableData,
      tablePagination: { current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: this.showTotal,
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      sessionTplId: null,
      sessionConfigTplData: [],
      initBtnEvent: {},
      initTableStyle: {},
      initTableEvent: [],
      tableToolbarMenu: [],
      tableToolbarList: [],
      footerToolbarList: [],
      customRowIdxBtnObj: {},
      customRowIdxMenuObj: {},
      customRowIdxTagsObj: {},
      tableColumnSorter: {
        column: 'createTime',
        order: 'desc'
      },
      formModel: {},
      formEvent: {},
      dealApi: {
        page: { S_PAGE_ID: '', S_PAGE_VER: 'v0.02', S_PARTITION: 32 },
        list: { S_PAGE_ID: '', S_PAGE_VER: 'v0.02', S_PARTITION: 32 }
      },
      dealParam: {
        page: { S_DY_PARAM: [] },
        delete: { S_DY_PARAM: [] }
      },
      sessionFilterList: '',
      columnBtnAction: {},
      showAction: ['action'],
      showTags: ['I_FLAG_text'],
      showInputs: ['S_ID'],
      enumData: {},
      columnOrderParam: {},
      columnFilterParam: {},
      activeEnumData: {},
      activeFilters: [],
      columnFiltersData: {},
      activeColumnFiltersData: {},
      formRowCollapseKey: {},
      formRowActiveData: {},
      formColActiveData: {},
      listColActiveList: [],
      listColActiveData: {},
    }
  },
  watch: {
    footerToolbarList(val) {
      this.$emit('triggerFooterToolbarData', val)
    },
    paramData(val) {
      const _this = this
      // this.tableOnLoadData();
      _this.initFormObjValue(val)
      _this.$nextTick(() => {
        console.debug('watch 数据变化 val ', val)
        _this.searchQuery()
      })
    }
  },
  mounted() {
    // 延迟加载采用mounted重新挂载
    this.clientWidth = document.body.clientWidth
    window.addEventListener('resize', this.resizeTest)
    if (undefined === this.paramData) {
      return
    }
    if (Object.keys(this.paramData).length !== 0) {
      console.debug('mount 数据变化 val ', this.paramData)
      this.tableOnLoadData()
    }
  },
  methods: {
    resizeTest() {
      const thisObj = this
      const formList = thisObj.initUiVal[thisObj.initFormKey]
      this.clientWidth = document.body.clientWidth
      initFormListWidth(thisObj, formList)
    },
    clickIconEvent(titleIcon) {
      console.log('点击图标事件样例', titleIcon)
    },
    changeAppContainnerCssObj() {
      this.appContainerCssClass = this.appInnerContainerCssClass
    },
    changeInitSrcObj(newInitSrcObj) {
      this.initSrcObj.initSrcSearch = false
      // this.initSrcObj = newInitSrcObj
    },
    setInitReturnSetFormData(initReturnSetFormData) {
      this.initReturnSetFormData = initReturnSetFormData
    },
    handleSearch(selectedKeys, confirm, dataIndex) {
      confirm()
      this.searchText = selectedKeys[0]
      this.searchedColumn = dataIndex
    },

    handleReset(clearFilters) {
      clearFilters()
      this.columnFilterParam = Object.assign({}, {})
      this.searchText = ''
    },
    tableInputChange(value, key, rowIdx) {
      this.tableData[rowIdx][key] = value
    },
    tableInputNumberChange(value, key, rowIdx) {
      this.tableData[rowIdx][key] = value
    },
    onChange(checkedValues) {
      console.log('checked = ', checkedValues)
      console.log('value = ', this.value)
    },
    changeCheckable() {
      if (undefined !== this.initSrcObj.initSrcType) {
        if (this.initSrcObj.initSrcType === 'checkbox' || this.initSrcObj.initSrcType === 'radio') {
          this.rowSelectType = this.initSrcObj.initSrcType
        }
      }
    },
    initTableRowKey() {
      const thisObj = this
      initTableRowKey(thisObj)
    },
    initEnumParam() {
      const thisObj = this
      initEnumParam(thisObj)
    },
    getLocalParamDataSet() {
      // 入参数据集
      const thisObj = this
      const record = Object.assign({}, thisObj.openParam, thisObj.initData, thisObj.openReturnData, thisObj.formModel)
      return record
    },
    changePanelInitUiVal(formItem, triggerObj) {
      // 变更呈现数据
      const selectedRow = this.tableSelectedRow
      const localParamDataSet = this.getLocalParamDataSet()
      this.$emit('tableChangeEvent', formItem, triggerObj, localParamDataSet, selectedRow)
    },
    changeUiEventTrigger(formItem, triggerObj) {
      const selectedRow = this.tableSelectedRow
      const localParamDataSet = this.getLocalParamDataSet()
      this.$emit('uiChangeEvent', formItem, triggerObj, localParamDataSet, selectedRow)
    },
    changeColumnList(formItem, triggerObj) {
      const thisObj = this
      changeColumnList(thisObj, triggerObj, thisObj.globalData)
    },
    initForm() {
      const thisObj = this
      initForm(thisObj)
    },
    changeForm(triggerObj, param) {
      const thisObj = this
      changeForm(thisObj, triggerObj, param)
    },
    otherCompSetValClearData() {
      const thisObj = this
      const tmpData = Object.assign({})
      thisObj.tableQueryParam = Object.assign(tmpData)
      thisObj.initData = Object.assign(tmpData)
      thisObj.openReturnData = Object.assign(tmpData)
      thisObj.formModel = Object.assign(tmpData)
      thisObj.globalData = Object.assign(tmpData)
      thisObj.initSrcObj = Object.assign(tmpData)
    },
    otherCompSetValOpenParam(triggerObj, param, initSrcObj) {
      const thisObj = this
      this.otherCompSetValClearData()
      this.initSrcObj = initSrcObj
      this.openParam = Object.assign({}, param)
      thisObj.formModel = Object.assign({}, this.openParam, param)
      const tmpGlobalData = {}
      tmpGlobalData.tableId = thisObj.tableId
      tmpGlobalData.initSrcObj = thisObj.initSrcObj
      tmpGlobalData.clickRow = {}
      tmpGlobalData.clickItem = {}
      tmpGlobalData.openParam = param
      tmpGlobalData.formModel = thisObj.formModel
      tmpGlobalData.initData = thisObj.initData
      tmpGlobalData.activeEnumData = thisObj.initData
      tmpGlobalData.tableSelectedRow = []
      tmpGlobalData.globalParam = getGlobalParam(thisObj)
      thisObj.globalData = tmpGlobalData
      this.changeToolbar(triggerObj)
      this.changeToolbarMenu(triggerObj)
      if (thisObj.initSrcObj.initSrcSearch === undefined || thisObj.initSrcObj.initSrcSearch === true) {
        thisObj.triggerInitBtn()
      }
    },
    changeToolbar(triggerObj) {
      // 设置具体变量字段呈现
      // triggerObj 触发对象,没有填写null
      const thisObj = this
      // const record = thisObj.getLocalParamDataSet()
      changeToolbar(thisObj, triggerObj, thisObj.globalData)
    },
    initToolbarMenu() {
      // 一开始初始化按钮栏
      const thisObj = this
      initToolbarMenu(thisObj)
    },
    changeToolbarMenu(triggerObj) {
      // 设置具体变量字段呈现
      // triggerObj 触发对象,没有填写null
      const thisObj = this
      // const record = thisObj.getLocalParamDataSet()
      changeToolbarMenu(thisObj, triggerObj, thisObj.globalData)
    },
    initRules() {
      // 开始初始化所有项目为必填
      const thisObj = this
      initRules(thisObj)
    },
    changeFormRules() {
      // 加载结束后,根据规则调整对应表单校验方式
      const thisObj = this
      changeFormRules(thisObj)
    },
    changeFormKeyRules(key) {
      // 单个变量校验规则调整设置
      const thisObj = this
      changeFormKeyRules(thisObj, key)
    },
    initFormFnParam() {
      // 一开始初始化读写参数
      const thisObj = this
      initFormFnParam(thisObj, true)
    },
    changeFormFnParam() {
      // 设置初始加载表单读写参数
      const thisObj = this
      changeFormFnParam(thisObj)
    },
    changeFormKeyFnParam(key) {
      const thisObj = this
      changeFormKeyFnParam(thisObj, key)
    },
    initTblEvent() {
      const thisObj = this
      initTableEvent(thisObj)
    },
    clearIniUi() {
      // 清除初始化数据
      const tmpArr = Object.assign([])
      const tmpData = Object.assign({})
      this.initUiVal = Object.assign(tmpData)
      this.initData = Object.assign(tmpData)
      this.nowRow = Object.assign(tmpData)
      this.openParam = Object.assign(tmpData)
      this.formModel = Object.assign(tmpData)
      this.formList = Object.assign(tmpData)
      this.activeEnumData = Object.assign(tmpData)
      this.tableToolbarMenu = Object.assign(tmpArr)
      this.tableToolbarList = Object.assign(tmpArr)
    },
    initUI(val, param, initSrcObj) {
      const thisObj = this
      this.initSrcObj = initSrcObj
      this.openParam = param
      this.formModel = Object.assign({}, this.openParam)
      this.initLoadObj.loadPanelId = val.panel.panelTplId
      this.initLoadObj.loadPanelVer = val.panel.panelTplVer
      this.initLoadObj.panelWidth = val.panel.panelWidth
      this.initLoadObj.defPanelWidth = this.defPanelWidth
      const tmpGlobalData = {}
      tmpGlobalData.tableId = thisObj.tableId
      tmpGlobalData.initSrcObj = thisObj.initSrcObj
      tmpGlobalData.clickRow = {}
      tmpGlobalData.clickItem = {}
      tmpGlobalData.openParam = param
      tmpGlobalData.formModel = thisObj.formModel
      tmpGlobalData.initData = thisObj.initData
      tmpGlobalData.tableSelectedRow = []
      tmpGlobalData.globalParam = getGlobalParam(thisObj)
      thisObj.globalData = tmpGlobalData
      const tmpVal = Object.assign({}, val)
      this.clearIniUi()
      this.initUiVal = Object.assign({}, tmpVal)
      initLazyFormRules(this)
      this.initTableRowKey()
      this.initEnumParam()
      // this.initColShow()

      this.initFormFnParam()
      this.initForm()
      this.initRules()
      initFooterToolbarList(this)
      initToolbar(this)
      initToolbarMenu(this)
      initColumnList(this)
      initColumnListBtn(this)
      this.initTblEvent()
      // this.initEcharts()
      if (undefined === val || undefined === val.urlList) {
        return
      }
      initDealApi(this, val)
      const pagination = this.getPaginationVal(val)
      this.tablePagination = Object.assign({}, pagination)
      if (undefined !== val.style) {
        this.initTableStyle = val.style
      }
      this.changeCheckable()
      // this.initShowEchart(val)

      if (this.initUiVal.sessionData !== undefined && this.initUiVal.sessionData.sessionConfigTpl !== undefined) {
        this.sessionConfigTplData = this.initUiVal.sessionData.sessionConfigTpl
      }
      thisObj.$nextTick(() => {
        thisObj.changeFormRules()
        thisObj.changeFormFnParam()
        thisObj.changeToolbar(null)
        thisObj.changeToolbarMenu(null)
        handleInit(thisObj)
        if (thisObj.openParam.tableData !== undefined) {
          thisObj.tableData = thisObj.openParam.tableData
        }
      })
    },
    triggerInitBtn() {
      const thisObj = this
      if (thisObj.initUiVal.toolbar !== undefined &&
        thisObj.initUiVal.toolbar.initBtnKey !== undefined &&
        thisObj.initUiVal.toolbar.initBtnKey.length > 0
      ) {
        const initBtnKey = thisObj.initUiVal.toolbar.initBtnKey
        for (const i in initBtnKey) {
          const btnKey = initBtnKey[i]
          console.log('触发初始化', btnKey)
          execClickBtn(thisObj, thisObj.globalData, btnKey)
        }
      } else {
        thisObj.tableQueryByParam(thisObj.globalData)
      }
    },
    searchList() {
      console.log('列表查询函数')
      fetchPageData(this, this.getTableSearchForm())
    },
    searchPage() {
      console.log('分页查询函数')
      fetchPageData(this, this.getTableSearchForm())
    },

    getSessionHourGroupList() {
      this.sessionFilterList = 'I_CREATE_YEAR,I_CREATE_MONTH,I_CREATE_DAY,I_CREATE_HOUR'
      this.queryEchartsData()
    },
    getSessionDayGroupList() {
      this.sessionFilterList = 'I_CREATE_YEAR,I_CREATE_MONTH,I_CREATE_DAY'
      this.queryEchartsData()
    },
    getSessionMonthGroupList() {
      this.sessionFilterList = 'I_CREATE_YEAR,I_CREATE_MONTH'
      this.queryEchartsData()
    },
    initEcharts() {
      if (!this.tableObjParam.showEchart) {
        this.showChart.defaultShow = false
        return
      }
      const chartObj = document.getElementById(this.tableEchartId)
      if (chartObj === null || undefined === chartObj || undefined === chartObj) {
        return
      }
      this.viewChart = echarts.init(chartObj)
    },
    initEchartsData() {
      const optionData = {
        xAxis: {
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        series: [{
          data: [820, 932, 901, 934, 1290, 1330, 1320]
        }]
      }
      if (this.viewChart !== null) {
        this.viewChart.setOption(optionData)
      }
    },

    queryEchartsData() {
      const _this = this
      const urlKey = this.ehUrlKey.S_BLOCK_URL_KEY
      const echartsParam = { viewKey: 5 }
      const dealParam = getDealParam(this, urlKey, this.getTableSearchForm())
      const newParam = Object.assign({}, echartsParam, dealParam)
      newParam.sessionFilterList = this.sessionFilterList
      newParam.S_BLOCK_EH_ID = this.ehUrlKey.S_BLOCK_EH_ID
      _this.loading = true
      submitDealReq(newParam).then((res) => {
        _this.loading = false
        const optionData = res.data.data
        if (this.viewChart !== null) {
          this.viewChart.setOption(optionData)
        }
      }).catch(reason => {
        _this.loading = false
        console.log('reason' + reason)
      })
    },
    queryUiTplData() {
      const _this = this
      const urlKey = this.ehUrlKey.S_BLOCK_URL_KEY
      const echartsParam = { viewKey: 5 }
      const dealParam = getDealParam(this, urlKey, this.getTableSearchForm())
      const newParam = Object.assign({}, echartsParam, dealParam)
      newParam.sessionFilterList = this.sessionFilterList
      _this.loading = true
      submitDealReq(newParam).then((res) => {
        _this.loading = false
        const optionData = res.data.data
        if (this.viewChart !== null) {
          this.viewChart.setOption(optionData)
        }
      }).catch(reason => {
        _this.loading = false
        console.log('reason' + reason)
      })
    },

    initShowEchart(val) {
      if (this.tableObjParam.showEchart) {
        if (undefined === val.ehOptions || val.ehOptions === 'undefined' || val.ehOptions === null) {
          this.showChart.defaultShow = false
        } else {
          const optionData = val.ehOptions.data
          if (this.viewChart !== null && undefined !== optionData) {
            this.showChart.defaultShow = true
            this.viewChart.setOption(optionData)
            this.initEchartsData()
            this.ehUrlKey = optionData.urlKey
          } else {
            this.showChart.defaultShow = false
          }
        }
      }
    },
    selectFirstRow() {
      const _this = this
      if (undefined !== _this.tableObjParam) {
        _this.$emit(_this.tableObjParam.selectFirstRow, this.tableFirstRow)
      }
    },
    clearEmpty(item) {
    },
    processCustomRowTags(record, rowIndex) {
      for (const tagIdx in this.showTags) {
        const tag = this.showTags[tagIdx]
        const val = record[tag]
        let varArr = []
        if (undefined !== val) {
          varArr = val.split(',')
        }
        const tagData = {}
        tagData[rowIndex] = varArr
        this.customRowIdxTagsObj[tag] = tagData
      }
    },
    processCustomRow(record, rowIndex) {
      const thisObj = this
      const tmpGlobalData = {}
      thisObj.globalData.clickSrc = 'customRow'
      tmpGlobalData.tableId = thisObj.tableId
      tmpGlobalData.initSrcObj = thisObj.initSrcObj
      tmpGlobalData.clickRow = record
      tmpGlobalData.clickItem = {}
      tmpGlobalData.openParam = thisObj.openParam
      tmpGlobalData.formModel = thisObj.formModel
      tmpGlobalData.initData = thisObj.initData
      // tmpGlobalData.tableSelectedRow = []
      tmpGlobalData.globalParam = Object.assign({}, getGlobalParam(thisObj), record)
      this.processCustomRowTags(record, rowIndex)
      initRowBtn(thisObj, tmpGlobalData, rowIndex)
      return {
        on: {
          // 鼠标单击行
          click: event => {
            thisObj.globalData.clickSrc = 'click'
            thisObj.globalData.tableId = thisObj.tableId
            thisObj.globalData.initSrcObj = thisObj.initSrcObj
            thisObj.globalData.clickRow = record
            thisObj.globalData.clickItem = {}
            thisObj.globalData.openParam = thisObj.openParam
            thisObj.globalData.formModel = thisObj.formModel
            thisObj.globalData.initData = thisObj.initData
            thisObj.globalData.globalParam = getGlobalParam(thisObj)
            thisObj.globalData.activeEnumData = thisObj.activeEnumData
            changeTableEvent(thisObj, 'click', '单击事件', thisObj.globalData)
          },
          dblclick: (event) => {
            thisObj.globalData.clickSrc = 'dblclick'
            thisObj.globalData.tableId = thisObj.tableId
            thisObj.globalData.initSrcObj = thisObj.initSrcObj
            thisObj.globalData.clickRow = record
            thisObj.globalData.clickItem = {}
            thisObj.globalData.openParam = thisObj.openParam
            thisObj.globalData.formModel = thisObj.formModel
            thisObj.globalData.initData = thisObj.initData
            thisObj.globalData.globalParam = getGlobalParam(thisObj)
            thisObj.globalData.activeEnumData = thisObj.activeEnumData
            changeTableEvent(thisObj, 'dblclick', '双击事件', thisObj.globalData)
          },
          contextmenu: (event) => {
            // 不对外开放
            thisObj.globalData.clickSrc = 'contextmenu'
            thisObj.globalData.tableId = thisObj.tableId
            thisObj.globalData.initSrcObj = thisObj.initSrcObj
            thisObj.globalData.clickRow = record
            thisObj.globalData.clickItem = {}
            thisObj.globalData.openParam = thisObj.openParam
            thisObj.globalData.formModel = thisObj.formModel
            thisObj.globalData.initData = thisObj.initData
            thisObj.globalData.globalParam = getGlobalParam(thisObj)
            thisObj.globalData.activeEnumData = thisObj.activeEnumData
            if (thisObj.tableSelectedRow.length === 0) {
              thisObj.globalData.tableSelectedRow = []
              thisObj.globalData.tableSelectedRow.push(record)
            }
            changeTableEvent(thisObj, 'contextmenu', '右键菜单事件', thisObj.globalData)
          }
        }
      }
    },
    processCustomRowOnClick(globalData, rowIndex) {
      const _this = this
      _this.$emit(_this.tableEvent.rowOnClick, globalData)
    },
    processCustomRowOnDblClick(globalData, rowIndex) {
      const _this = this
      _this.$emit(_this.tableEvent.rowOnDblClick, globalData)
    },
    processOnClick(text, record, rowIndex, rowColumn) {
      const thisObj = this
      thisObj.globalData.clickSrc = 'columnClick'
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.clickRow = record
      thisObj.globalData.clickItem = {}
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      const refOpenObj = getRefOpenObj(thisObj, rowColumn, thisObj.globalData)
      if (refOpenObj !== null) {
        rowColumn.refOpen = refOpenObj
        this.$emit('openGeneralModal', rowColumn, thisObj.globalData)
      }
      // this.$message.success(text);
    },
    inputChangeEventControlObj(formItem) {
      const thisObj = this
      const record = Object.assign({}, thisObj.initData, thisObj.openParam, thisObj.formModel)
      inputChangeEventControlObj(thisObj, formItem, record)
    },
    changeUploadFile(btnItem) {
      this.nowBtnItem = btnItem
    },
    importFileData(btnItem, data) {
      console.log('点击导入文件事件.', btnItem)
    },
    tableOperatorBtnUpload(btnItem, data) {
      console.log('点击导入文件事件.上传', btnItem)
      const thisObj = this
      btnUploadFile(thisObj, btnItem, data)
    },
    inputSearch(formItem, data) {
      const thisObj = this
      thisObj.triggerInitBtn()
    },
    inputSelectSearch(formItem, data) {
      const thisObj = this
      const triggerObj = {}
      triggerObj.s_RULE_TPL_KEY = formItem.model
      const param = {}
      thisObj.globalData.globalParam[formItem.model] = data
      thisObj.globalData.formModel[formItem.model] = data
      changeLoadEnumList(thisObj, triggerObj, param)
    },
    inputChangeEvent(formItem, data) {
      const thisObj = this
      inputChangeEvent(thisObj, formItem)
    },
    inputOpenGeneralModal(formItem, globalData) {
      this.$emit('openGeneralModal', formItem, globalData)
    },
    getPaginationVal(val) {
      const pagination = this.tablePagination
      pagination.pageSize = this.tablePagination.pageSize
      pagination.pageSizeOptions = this.tablePagination.pageSizeOptions
      return pagination
    },
    showTotal(total, range, t, c) {
      return '第' + range[0] + '-' + range[1] + '条记录,共' + total + '条'
    },
    getCallFnByFnType(btnItem) {
      this.nowBtnItem = btnItem
      return getCallFnByFnType(btnItem)
    },
    executeBatchRemoteDelete(btnItem, globalData) {
      deleteBatchRemoteRecord(this, globalData)
    },
    executeRemoteDelete(btnItem, globalData) {
      // 本地删除
      deleteRemoteRecord(this, globalData)
    },
    executeBatchLocalDelete(btnItem, globalData) {
      deleteBatchLocalList(this, globalData)
    },
    executeLocalDelete(btnItem, globalData) {
      // 本地删除
      deleteLocalList(this, globalData)
    },
    executeTmpSave(btnItem, globalData) {
      // 暂存
    },
    columnBtnOnClick(btnItem, record) {
      const thisObj = this
      thisObj.globalData.clickSrc = 'columnClick'
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.clickRow = record
      thisObj.globalData.clickItem = btnItem
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      // thisObj.globalData.tableSelectedRow = Object.assign([], thisObj.tableSelectedRow)
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      const fn = this.getCallFnByFnType(btnItem)
      if (fn) {
        console.log('执行函数@', fn, thisObj.globalData)
        this[fn](btnItem, thisObj.globalData)
      } else {
        this.$message.warning('按钮未配置响应函数')
      }
    },
    tableOperatorBtnOnClick(btnItem) {
      const thisObj = this
      thisObj.globalData.clickSrc = 'toolbarClick'
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.clickRow = {}
      thisObj.globalData.clickItem = btnItem
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      thisObj.globalData.tableSelectedRow = Object.assign([], thisObj.tableSelectedRow)
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      const fn = this.getCallFnByFnType(btnItem)
      this[fn](btnItem, thisObj.globalData)
    },
    setTableSearchForm(record) {
      const _this = this
      _this.formModel = Object.assign({}, this.formModel, record)
    },
    getTableSearchForm() {
      return Object.assign({}, this.formModel)
    },
    searchQuery(btnItem, selectedRow) {
      this.tablePagination.current = 1
      this.tableOnLoadData(btnItem, selectedRow)
    },
    tableQueryByParam(param) {
      const _this = this
      _this.$nextTick(() => {
        _this.tableOnLoadData()
      })
    },

    tableOnChange(pagination, filters, sorter) {
      const thisObj = this
      thisObj.globalData.clickSrc = 'tableHeadClick'
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.clickRow = {}
      thisObj.globalData.clickItem = {}
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      if (Object.keys(sorter).length > 0) {
        const sortObj = {}
        // sortObj.field = sorter.field
        sortObj[sorter.field] = sorter.order === 'ascend' ? 'asc' : 'desc'
        thisObj.columnOrderParam = sortObj
        thisObj.globalData.columnOrderParam = sortObj
      } else {
        thisObj.columnOrderParam = Object.assign({}, {})
      }
      thisObj.columnFilterParam = Object.assign({}, filters)
      thisObj.globalData.columnFilterParam = filters
      changeTableEvent(thisObj, 'change', '分页或表头事件', thisObj.globalData)
      this.tablePagination = pagination
      this.tableOnLoadData()
    },
    tableOnSelect(selected, record) {
      this.tableSelectTips = true
      this.tableSelectedKey = selected
      if (selected.length === 0) {
        this.tableSelectedRow = []
      } else {
        this.tableSelectedRow = record
      }
      const thisObj = this
      thisObj.globalData.clickSrc = 'tableSelectClick'
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.tableSelectedRow = record
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.clickItem = {}
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      thisObj.globalData.activeEnumData = thisObj.activeEnumData
      thisObj.globalData.tableSelectedRow = record
      if (record instanceof Array) {
        thisObj.globalData.clickRow = record[0]
      } else {
        thisObj.globalData.clickRow = record
      }
      this.$emit(this.tableEvent.select, thisObj.globalData)
      changeTableEvent(thisObj, 'onSelect', '选中事件')
    },
    btnClickEvent(btnItem, record) {
      const thisObj = this
      console.log('btnClickEvent', record)
      if (btnItem.fnType === 97) {
        this.saveSessionFormData(btnItem, record)
      } else if (btnItem.fnType === 99) {
        thisObj.searchSessionTplData(btnItem, thisObj.globalData)
      } else if (btnItem.fnType === 92) {
        thisObj.openLocalSessionTplList(btnItem, thisObj.globalData)
      } else if (btnItem.fnType === 93) {
        thisObj.viewSessionFormDataList(btnItem, thisObj.globalData)
      } else if (btnItem.fnType === 94 || btnItem.fnType === 95) {
        // this.searchInitData(btnItem, record)
        searchSessionFormData(thisObj, thisObj.globalData)
      // }
      // else if (btnItem.fnType === 95) {
      //   console.log('00000000')
        // this.searchSessionFormData(btnItem, record)
      } else if (btnItem.fnType === 96) {
        searchSessionTpl(thisObj, thisObj.globalData)
      } else {
        this.$emit('btnClickEvent', btnItem, record)
      }
    },
    viewSessionFormDataList(btnItem, record) {
      const refOpenObj = getOpenLocalFormList()
      btnItem.refOpen = refOpenObj
      const localFormData = {}
      localFormData.S_PAGE_ID_IDX = this.uiPageUrl.S_UI_PAGE_ID_IDX_2025
      localFormData.S_PAGE_VER_IDX = this.uiPageUrl.S_UI_PAGE_VER_IDX_2025
      localFormData.S_PANEL_TPL_ID = this.initLoadObj.loadPanelId
      localFormData.S_PANEL_TPL_VER = this.initLoadObj.loadPanelVer
      const tmpGlobalData = {}
      tmpGlobalData.globalParam = localFormData
      tmpGlobalData.openParam = localFormData
      this.$emit(this.tableEvent.generalModal, btnItem, tmpGlobalData)
    },
    openLocalSessionTplList(btnItem, record) {
      const refOpenObj = getOpenLocalSessionTplList()
      btnItem.refOpen = refOpenObj
      const localFormData = {}
      localFormData.S_PAGE_ID_IDX = this.uiPageUrl.S_UI_PAGE_ID_IDX_2025
      localFormData.S_PAGE_VER_IDX = this.uiPageUrl.S_UI_PAGE_VER_IDX_2025
      localFormData.S_PANEL_TPL_ID = this.initLoadObj.loadPanelId
      localFormData.S_PANEL_TPL_VER = this.initLoadObj.loadPanelVer
      localFormData.S_FORM_BLOCK_TPL_ID = this.initLoadObj.loadFormId
      localFormData.S_LIST_BLOCK_TPL_ID = this.initLoadObj.loadListId
      localFormData.S_BTN_BLOCK_TPL_ID = this.initLoadObj.loadBtnId
      localFormData.openUi = 'tpl'
      const tmpGlobalData = {}
      tmpGlobalData.globalParam = localFormData
      tmpGlobalData.openParam = localFormData
      this.$emit(this.tableEvent.generalModal, btnItem, tmpGlobalData)
    },
    saveSessionFormData(btnItem, record) {
      const dataCompKey = this.initUiVal.formList.dataCompKey
      const tplCompKey = this.initUiVal.formList.tplCompKey
      const refOpenObj = getOpenLocalFormModel()
      btnItem.refOpen = refOpenObj
      this.formModel.S_FORM_DATA = undefined
      this.formModel[dataCompKey] = undefined
      const S_FORM_DATA = JSON.stringify(this.formModel)
      const localFormData = {}
      localFormData.S_FORM_DATA = S_FORM_DATA
      localFormData.S_PAGE_ID_IDX = this.uiPageUrl.S_UI_PAGE_ID_IDX_2025
      localFormData.S_PAGE_VER_IDX = this.uiPageUrl.S_UI_PAGE_VER_IDX_2025
      localFormData.S_BLOCK_TPL_ID = this.initLoadObj.loadFormId
      localFormData.S_PANEL_TPL_ID = this.initLoadObj.loadPanelId
      localFormData.S_PANEL_TPL_VER = this.initLoadObj.loadPanelVer
      if (this.formModel[tplCompKey] !== undefined) {
        localFormData.I_SESSION_TPL_ID = this.formModel[tplCompKey]
      } else {
        localFormData.I_SESSION_TPL_ID = this.sessionTplId
      }
      const tmpGlobalData = {}
      tmpGlobalData.globalParam = localFormData
      tmpGlobalData.openParam = localFormData
      this.$emit(this.tableEvent.generalModal, btnItem, tmpGlobalData)
    },
    searchSessionTplData(btnItem, record) {
      this.sessionTplId = btnItem.id
      console.log('searchSessionTplData btnItem',btnItem)
      const thisObj = this
      loadSessionUIData(btnItem, thisObj, thisObj.globalData)
    },
    searchSessionFormData(btnItem, record) {
      console.log('searchSessionFormData btnItem',btnItem)
      const thisObj = this
      loadSessionFormData(btnItem, thisObj, thisObj.globalData)
    },
    beforeInitData(btnItem, record) {
      const thisObj = this
      beforeInitData(thisObj, thisObj.globalData)
    },
    searchInitData(btnItem, record) {
      const thisObj = this
      beforeInitData(thisObj, thisObj.globalData)
    },
    openGeneralModal(btnItem, globalData) {
      const refOpenObj = getRefOpenObj(this, btnItem, globalData)
      if (refOpenObj !== null) {
        btnItem.refOpen = Object.assign({}, refOpenObj)
        // if (this.tableEvent.generalModal !== '') {
        this.$emit(this.tableEvent.generalModal, btnItem, globalData)
        // }
      } else {
        this.$message.warning('无满足条件开窗数据,请联系管理员.')
      }
    },
    uploadFTPFile(btnItem, globalData) {
      console.log('上报', btnItem)
      this.globalData.globalParam.pushDynamicKey = 'pushDynamicKey'
    },
    downloadFTPFile(btnItem, globalData) {
      console.log('下载', btnItem)
    },
    downloadUploadFile(btnItem, globalData) {
      const record = globalData.clickRow
      // 下载上传文件  clickRow
      let S_ID = record.ID
      let S_FILE_NAME = record.FILE_NAME
      const inputParam = getFnInputParam(record, this.globalData, btnItem)
      if (inputParam.S_ID !== undefined) {
        S_ID = inputParam.S_ID
      } else {
        inputParam.S_ID = S_ID
      }
      if (inputParam.S_FILE_NAME !== undefined) {
        S_FILE_NAME = inputParam.S_FILE_NAME
      } else {
        inputParam.S_FILE_NAME = S_FILE_NAME
      }
      const url = '/autodeal/file/ctr/download/' + S_ID
      let downParam = {}
      if (btnItem.refSetOpenVal !== undefined) {
        downParam = inputParam
      }
      request.download(url, downParam, S_FILE_NAME)
    },
    appendTableData(rows) {
      for (const idx in rows) {
        this.tableData.push(rows[idx])
      }
      this.tablePagination.total = this.tableData.length
    },
    setTableData(rows) {
      this.tableData = []
      for (const idx in rows) {
        this.tableData.push(rows[idx])
      }
      this.tablePagination.total = this.tableData.length
    },
    clearTableData() {
      this.tableData = []
      this.tablePagination.total = 0
    },
    getTableData() {
      return this.tableData
    },
    tableSelectedTitle() {
      return !this.tableSelectedRow.title ? '' : this.tableSelectedRow.title
    },
    tableClearSelected() {
      this.hiding = true
      this.tableSelectTips = false
      this.tableSelectedRow = []
      this.tableSelectedKey = []
    },
    openTableUpload(btnItem, record) {
      this.$emit(this.tableEvent.impModal, btnItem, record, this.dealApi)
    },

    exportFileData(btnItem, record) {
      const _this = this
      let param = {}
      if (undefined !== record) {
        param = Object.assign({}, record)
      }
      _this.$emit('openTableDownLoad', btnItem, record)
    },
    openTableDownLoadTemplate(btnItem, record) {
      const _this = this
      let param = {}
      if (undefined !== record) {
        param = Object.assign({}, record)
      }
      param.url = '/run/ctr/submitUploadTemplate/'
      param.iPageNo = 1
      param.iPageSize = 1
      param = Object.assign({}, param, _this.dealApi.impUrl)
      this.openTableExport(param)
    },
    openTableExport(param) {
    },
    openTableLoad(btnItem, record) {
      const _this = this
      if (undefined === btnItem.urlKey || btnItem.urlKey === null || btnItem.urlKey === '') {
        btnItem.urlKey = 'load'
      }
      _this.execute(btnItem, record)
    },
    openTableMenuLoad(btnItem, record) {
      const _this = this
      if (undefined === btnItem.urlKey || btnItem.urlKey === null || btnItem.urlKey === '') {
        btnItem.urlKey = 'menuLoad'
      }
      _this.execute(btnItem, record)
    },
    openSessionGeneralModal(btnItem, record) {
      const sessionRecord = Object.assign({}, this.initLoadObj, this.uiPageUrl)
      sessionRecord.I_APP_ID = I_APP_ID
      const thisObj = this
      thisObj.globalData.clickSrc = 'sessionClick'
      thisObj.globalData.tableId = thisObj.tableId
      thisObj.globalData.initSrcObj = thisObj.initSrcObj
      thisObj.globalData.clickRow = record
      thisObj.globalData.clickItem = {}
      thisObj.globalData.openParam = sessionRecord
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.initLoadObj = thisObj.initLoadObj
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      this.openGeneralModal(btnItem, thisObj.globalData)
    },
    executeLocalEvent(btnItem, record) {
      const eventKey = btnItem.key
      const eventList = this.initUiVal.toolbar.btnEvent[eventKey]
      if (!(undefined === eventList || eventList.length === 0)) {
        const newBtnItem = {}
        newBtnItem.operateEvent = 'click'
        newBtnItem.name = btnItem.name
        newBtnItem.eventList = eventList
        inputChangeEventControlObj(this, newBtnItem, record)
      }
    },
    execute(btnItem, record) {
      executeRecord(this, btnItem, record)
    },
    clearSelections() {
      this.$refs[this.tableId].clearSelection()
    },
    clearSelectCellData() {
      this.selectCellRow = null
      this.selectCellCol = null
      this.selectCell = null
    },
    handleCellClick(row, column, cell, event) {
      this.selectCellRow = row
      this.selectCellCol = column
      this.selectCell = cell
    },
    tableOperatorBtnMenuCommand(command) {
      let btnMenuItem = null
      for (const i in this.initToolbarMenu) {
        const btnMenu = this.initToolbarMenu[i]
        if (btnMenu.key === command) {
          btnMenuItem = btnMenu
          break
        }
      }
      this.columnBtnOnClick(btnMenuItem, this.tableSelectedRow)
    },
    initFormObjValue(param) {
      this.formModel = Object.assign({}, this.formModel, param)
      this.tableQueryParam = Object.assign({}, this.tableQueryParam, param)
    },
    tableOnLoadData(btnItem, selectedRow) {
      this.search(btnItem, selectedRow)
    },
    search(btnItem, selectedRow) {
      const thisObj = this
      thisObj.globalData.tableSelectedRow = []
      thisObj.globalData.openParam = thisObj.openParam
      thisObj.globalData.formModel = thisObj.formModel
      thisObj.globalData.initData = thisObj.initData
      thisObj.globalData.clickRow = {}
      thisObj.globalData.clickItem = btnItem
      thisObj.globalData.globalParam = getGlobalParam(thisObj)
      // thisObj.globalData.tableSelectedRow = Object.assign([], thisObj.tableSelectedRow)
      fetchPageData(this, thisObj.globalData)
    },
    reloadLoadData(btnItem, data, modalKey, postParam) {
      this.search()
    },
    remoteDataSuccess(btnItem, returnData, modalKey, modalForm) {
      this.search()
    },
    insertSuccess(btnItem, returnData, modalKey, modalForm) {
      this.search()
    },
    updateSuccess(btnItem, returnData, modalKey, modalForm) {
      this.search()
    },
    deleteSuccess(btnItem, rowIds, record) {
      this.tableClearSelected()
      this.search()
    }
  }
}
</script>
<style>
  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
  .highlight {
    background-color: rgb(255, 192, 105);
    padding: 0px;
  }
</style>
